//===================================================
//Author      : GCL
//CreateTime  ：2/1/2019 12:51:53 PM
//Description ：
//===================================================
using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite;
using System.Text.RegularExpressions;
public class BasicTableReader : TableReader {

	public override JSONObject ToJSONObject (Mono.Data.Sqlite.SqliteDataReader reader)
	{
		JSONObject jo = new JSONObject();
		int fieldCount = reader.FieldCount;
		for( int i = 0; i < fieldCount; ++i )
		{
			//string fieldTypeName = reader.GetDataTypeName(i);
			string fieldName = reader.GetName(i);

			//fieldTypeName = fieldTypeName.ToLower();
            jo[fieldName] = reader.IsDBNull( i ) ? JSONObject.nullJO : new JSONObject( reader.GetValue( i ) );

   //         switch(fieldTypeName)
			//{
			//	case "double":
			//	{
			//		jo[fieldName] = reader.IsDBNull(i) ? JSONObject.nullJO : new JSONObject(reader.GetDouble(i));
			//		break;
			//	}
			//	case "float":
			//	{
			//		jo[fieldName] = reader.IsDBNull(i) ? JSONObject.nullJO : new JSONObject(reader.GetFloat(i));
			//		break;
			//	}
			//	case "integer":
   //             case "int":
			//	{
			//		jo[fieldName] = reader.IsDBNull(i) ? JSONObject.nullJO : new JSONObject(reader.GetInt32(i));
			//		break;
			//	}
			//	case "char":
			//	case "nvarchar":
			//	case "varchar":
			//	{
					
			//		jo[fieldName] = reader.IsDBNull(i) ? JSONObject.nullJO : new JSONObject(reader.GetString(i));
			//		break;
			//	}
			//}
		}
		return jo;
	}
}

